<template>
    <div class="addFeed" :style="'height:' + height + 'px;'">
        <div>
            <HeadTop :title="headTitle"></HeadTop>
            <div class="head-time">{{new Date | format}}</div>
        </div>
        <div class="addClass">
            <div class="addClass-title">药品信息</div>
            <div class="addClass-line"></div>
            <div class="addFeed-con">
                <div class="addFeed-con-name">药品名称</div>
                <div class="addFeed-con-msg">
                    <van-dropdown-menu>
                        <van-dropdown-item v-model="value" :options="opt" />
                    </van-dropdown-menu>
                </div>
            </div>
            <div class="addFeed-con">
                <div class="addFeed-con-name">计量单位</div>
                <div>
                    <input class="addFeed-con-msg" :value="opt[value].measurement" disabled/>
                </div>
            </div>
            <div class="addFeed-con">
                <div class="addFeed-con-name">原库存</div>
                <div>
                    <input class="addFeed-con-msg" :value="opt[value].num" disabled/>
                </div>
            </div>
            <div class="addFeed-con">
                <div class="addFeed-con-name">药品数量</div>
                <div>
                    <input class="addFeed-con-msg" v-model="fodderQuantity"/>
                </div>
            </div>
        </div>
        <div class="addClass-btn">
            <div class="addClass-btn-hold" @click="submit(0)">保存</div>
            <div class="addClass-btn-submit" @click="submit(1)">提交</div>
        </div>

    </div>
</template>
<script>
import { getMedictionList, addMedictionCheckReport } from '../../../../api/index.js'
import HeadTop from '../../../../components/headTop.vue'
import { getYYYYMMDD } from '../../../../api/unit.js'
export default {
  data () {
    return {
      headTitle: '药品盘库报表',
      value: 0,
      value2: 0,
      opt: [],
      opt2: [],
      height: document.documentElement.clientHeight,
      fodderQuantity: ''
    }
  },
  filters: {
    format: function (value) {
      return getYYYYMMDD(value).nTime
    }
  },
  async mounted () {
    let msg = await getMedictionList('a8e986eb-2d28-40cb-bdec-699c199d1e4c')
    let idx = 0
    msg.data.map(v => {
      v.text = v.medictionName
      v.value = idx
      idx++
    })
    this.opt = msg.data
    this.value = msg.data[0].value
  },
  methods: {
    async submit (v) {
      if (this.fodderQuantity === '') {
        this.$notify({ type: 'danger', message: '请输入数量' })
        return
      }
      let data = {
        medictionId: this.opt[this.value].id,
        medictionQuantityAfter: this.fodderQuantity,
        submit: v
      }
      let result = await addMedictionCheckReport(data)
      if (result.code === 10000) {
        this.$router.go(-1)
      } else {
        this.$notify({ type: 'danger', message: result.msg })
      }
    }
  },
  components: {
    HeadTop
  }
}
</script>

<style scoped>
    .addFeed{
        background: #e5e5e5;
    }
    .head-time{
        width:750px;
        height:109px;
        background: #fff;
        border-top: #e5e5e5 2px solid;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size:32px;
        font-weight: bold;
    }
    .addClass{
        background: #fff;
        width: 686px;
        border-top: #e5e5e5 solid 17px;
        padding: 40px 32px;
        font-size: 32px;
        overflow: hidden;
    }
    .addClass-title{
        padding-bottom: 40px;
        font-weight: bold;
        margin-left: 5px;
    }
    .addClass-line{
        background-color: #e5e5e5;
        height: 1px;
        width: 686px;
    }
    .addFeed-con{
        display: flex;
        font-size: 28px;
        color: #757575;
        height: 45px;
        line-height: 45px;
        margin-top: 34px;
    }
    .van-dropdown-menu{
        height: 45px;
        background: #f9f9f8;
        text-align: left;

    }
    .addFeed-con-name{
        width: 150px;
        margin-left: 12px;
    }
    .addFeed-con-msg{
        padding: 0 25px;
        width: 485px;
        background: #f9f9f8;
    }
    .addClass-title-text{
        width: 675px;
        background: #FBF8F9;
        line-height: 54px;
        border: 1px solid #e5e5e5;
    }
    .addClass-btn{
        width: 750px;
        background: #e5e5e5;
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 154px;
        font-size: 32px;
    }
    .addClass-btn-hold{
        width: 332px;
        height: 111px;
        line-height: 111px;
        text-align: center;
        background: #fff;
        font-weight: bold;
        color: #999;
    }
    .addClass-btn-submit{
        width: 332px;
        height: 111px;
        line-height: 111px;
        text-align: center;
        color: #009EEA;
        background: #fff;
        font-weight: bold;
    }
</style>
